package com.test.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cs.framework.jdbc.common.dao.CommonDao;
import com.test.dto.UserDto;
import com.test.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService {

	@Resource
	private CommonDao commonDao;

	/**
	 * 获取用户
	 * 
	 * @param name
	 *            名称
	 * @return
	 */
	public UserDto get(String name) {
		return commonDao.getById(UserDto.class, name);
	}

	/**
	 * 查询用户数
	 * 
	 * @param userDto
	 * @return
	 */
	public int count(UserDto userDto) {
		return commonDao.count("User.query", userDto);
	}

	/**
	 * 查询用户列表
	 * 
	 * @param userDto
	 * @return
	 */
	public List<UserDto> query(UserDto userDto) {
		return commonDao.selectList("User.query", userDto, userDto, UserDto.class);
	}

	/**
	 * 新增用户
	 * 
	 * @param userDto
	 * @return
	 */
	public UserDto save(UserDto userDto) {
		return commonDao.save(userDto);
	}

	/**
	 * 修改用户
	 * 
	 * @param userDto
	 * @return
	 */
	public UserDto update(UserDto userDto) {
		return commonDao.update(userDto);
	}

}
